const { app, BrowserWindow } = require('electron')
const path = require('path')

const createWindow = () => {
    console.log(process)
    const win = new BrowserWindow({
        width: 680,
        height: 750,
        // frame: false,
        // titleBarStyle: 'hidden',
        autoHideMenuBar: true,
        icon: path.join(__dirname, 'images/icon.png'),
        resizable: false,
        webPreferences: {
            preload: path.join(__dirname, 'preload.js')
        }
    })
    // 开发
    win.loadURL('http://127.0.0.1:5173/')
    win.webContents.openDevTools();
    // 生产
    // win.loadFile(path.resolve(__dirname, '../dist/index.html'))

}

app.whenReady().then(() => {
    createWindow()

    app.on('activate', () => {
        if (BrowserWindow.getAllWindows().length === 0) {
            createWindow()
        }
    })
})

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit()
    }
})